﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using PlottingBasics.LINQHelpers;

namespace t_PlottingBasics
{
    [TestClass]
    public class t_TakeAllBut
    {
        [TestMethod]
        public void TestNullSequence()
        {
            var stuff = new double[0];
            var result = stuff.TakeAllBut(0);
            Assert.AreEqual(0, result.Count(), "Expected null result");
        }

        [TestMethod]
        public void TestSingleSequence()
        {
            var stuff = new double[] { 1.0 };
            var result = stuff.TakeAllBut(0);
            Assert.AreEqual(1, result.Count(), "Expected all elements to show up");

            var result1 = stuff.TakeAllBut(1);
            Assert.AreEqual(0, result1.Count(), "Expected none back when we ask for same number of elements as are in the sequence");

            var result2 = stuff.TakeAllBut(10);
            Assert.AreEqual(0, result2.Count(), "Expected none when we ask for more than are there");
        }

        [TestMethod]
        public void TestBiggerSequence()
        {
            var stuff = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
            var result = stuff.TakeAllBut(0);
            Assert.AreEqual(7, result.Count(), "Expected all elements to show up");

            var result1 = stuff.TakeAllBut(1);
            Assert.AreEqual(6, result1.Count(), "Expected none back when we ask for same number of elements as are in the sequence");

            var result2 = stuff.TakeAllBut(10);
            Assert.AreEqual(0, result2.Count(), "Expected none when we ask for more than are there");

            var result3 = stuff.TakeAllBut(3).ToArray();
            Assert.AreEqual(4, result3.Count(), "Expected diferent number after take all but 3");
            for (int i = 0; i < 4; i++)
            {
                Assert.AreEqual(stuff[i], result3[i], "Incorrect array came back!");
            }
        }
    }
}